﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Data.SqlClient;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;

public partial class WebMaster_Controls_Sitemap : System.Web.UI.UserControl
{
    //ClassExecute.ClassExecute dt;
    //string str = BCDataCenter.Configuration.CurrentConnectionString;
    //static string error = "";
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            //if (Session["UserType"].ToString() != "ad")
            //{
            //    string sPath = HttpContext.Current.Request.Url.AbsolutePath.Substring(1);
            //    if ((sPath != "WebMaster/Default.aspx") && (sPath != "PageError/CustomError.aspx"))
            //    {
            //        DataTable db = (DataTable)Session["PageUrl"];
            //        IEnumerable<DataRow> query =
            //            from order in db.AsEnumerable()
            //            where order.Field<string>("PageUrl") == sPath
            //            select order;
            //        try
            //        {
            //            DataTable boundTable = query.CopyToDataTable<DataRow>();
            //        }
            //        catch
            //        {
            //            Response.Redirect("../Default.aspx");
            //        }
            //    }

                //string sPath = HttpContext.Current.Request.Url.AbsolutePath.Substring(1);
                //dt = new ClassExecute.ClassExecute();
                //string data = dt.GetDataDepend(str, "k_checkPages", CommandType.StoredProcedure, ref error,
                //    new SqlParameter("@username", Session["username"].ToString()),
                //    new SqlParameter("@Page", sPath));
                //if (data == "no")
                //{
                //    Response.Redirect("../Default.aspx");
                //}
            //}
        }
    }

    private bool IsWildcardMatch(String wildcard, String text, bool casesensitive)
    {
        System.Text.StringBuilder sb = new System.Text.StringBuilder(wildcard.Length + 10);
        sb.Append("^");
        for (int i = 0; i < wildcard.Length; i++)
        {
            char c = wildcard[i];
            switch (c)
            {
                case '*':
                    sb.Append(".*");
                    break;
                default:
                    sb.Append(System.Text.RegularExpressions.Regex.Escape(wildcard[i].ToString()));
                    break;
            }
        }
        sb.Append("$");

        System.Text.RegularExpressions.Regex regex;
        if (casesensitive)
            regex = new System.Text.RegularExpressions.Regex(sb.ToString(), System.Text.RegularExpressions.RegexOptions.None);
        else
            regex = new System.Text.RegularExpressions.Regex(sb.ToString(), System.Text.RegularExpressions.RegexOptions.IgnoreCase);

        return regex.IsMatch(text);
    }

    //protected void btLogOff_Click(object sender, EventArgs e)
    //{
    //    Session.Clear();
    //    Response.Redirect(BCDataCenter.Globals.ApplicationPath + "Default.aspx");
       
    //}
}
